$(document)
    .ready(function() {
        // 切换皮肤
        $('.y-skin').click(function(e) {
                $(this).toggleClass('.y-light-skin');
                if ($(this).hasClass('.y-light-skin')) {
                    $('.title-ico,.location-ico,.y-popPay-nextIco').attr('src', 'images/icon/next-light.png')
                    $('.y-sortIcon').attr('src', 'images/icon/tableIco1-light.png')
                    $('.y-trade-chageIco').attr('src', 'images/icon/changeIco-light.png')
                    $('.y-step-img').attr('src', 'images/step-light.png')
                    $('.common-css').attr('href', 'css/common-light.css')

                    //首页
                    $('.board-table .sortIcon').attr('src', 'images/icon/tableIco1-light.png')
                    $('.findcionText').attr('src', 'images/findcionText-light.png')
                    $('.safeText').attr('src', 'images/safeTitle-light.png')
                    $('.convenientText').attr('src', 'images/convenientText-light.png')
                    $('.enImg').attr('src', 'images/major_quick_highEfficiency-light.png')
                    $('.highEfficiencyBox').attr('src', 'images/highEfficiencyBox-light.png')
                    $('.majorBox').attr('src', 'images/majorBox-light.png')
                    $('.quickBox').attr('src', 'images/quickBox-light.png')

                    $('.j-board-table .sortIcon').attr('src', 'images/icon/trade_sortIcon-light.png')
                    $('.tabItem img').attr('src', 'images/icon/collectIcon-light.png')
                    $('.searchBar').attr('src', 'images/icon/search-light.png')
                    $('.y-searchBar').attr('src', 'images/icon/y-search-light.png')
                    $('.card-del').attr('src', 'images/icon/delIcon-light.png')
                    $('.qrcode-ico').attr('src', 'images/icon/qrcode-light.png')
                    $('.j-location img').attr('src', 'images/icon/tableIco2-light.png')

                } else {
                    $('.title-ico,.location-ico,.y-popPay-nextIco').attr('src', 'images/icon/next.png')
                    $('.y-sortIcon').attr('src', 'images/icon/tableIco1.png')
                    $('.y-trade-chageIco').attr('src', 'images/icon/changeIco.png')
                    $('.y-step-img').attr('src', 'images/step.png')
                    $('.common-css').attr('href', 'css/common.css')
                    
                    //首页
                    $('.board-table .sortIcon').attr('src', 'images/icon/tableIco1.png')
                    $('.findcionText').attr('src', 'images/findcionText.png')
                    $('.safeText').attr('src', 'images/safeTitle.png')
                    $('.convenientText').attr('src', 'images/convenientText.png')
                    $('.enImg').attr('src', 'images/major_quick_highEfficiency.png')
                    $('.highEfficiencyBox').attr('src', 'images/highEfficiencyBox.png')
                    $('.majorBox').attr('src', 'images/majorBox.png')
                    $('.quickBox').attr('src', 'images/quickBox.png')

                    $('.j-board-table .sortIcon').attr('src', 'images/icon/trade_sortIcon.png')
                    $('.tabItem img').attr('src', 'images/icon/collectIcon.png')
                    $('.searchBar').attr('src', 'images/icon/search.png')
                    $('.y-searchBar').attr('src', 'images/icon/y-search.png')
                    $('.card-del').attr('src', 'images/icon/delIcon.png')
                    $('.qrcode-ico').attr('src', 'images/icon/qrcode.png')
                    $('.j-location img').attr('src', 'images/icon/tableIco2.png')

                }
            })


            // select
        var lis = $(".y-options li");

        for (var i = 0; i < lis.length; i++) {
            lis[i].onclick = function() {
                $(this)
                    .parents('.y-filterList')
                    .find('.y-select-box')
                    .val(this.getAttribute("rel"));
                $(this)
                    .parents(".y-options")
                    .hide();
                $(this)
                    .parents('.y-replace')
                    .find(".y-current")
                    .html(this.innerHTML);
                getSelectVal(this);
            }
        }
        $(".y-replace")
            .mouseover(function() {
                $(this)
                    .find(".y-options")
                    .show();
            })
        $(".y-replace").mouseout(function() {
            $(this)
                .find(".y-options")
                .hide();
        })

        setBox();

        $(window).resize(function() {
            setBox();
        })
        $('.y-scroll-height').resize(function() {
            setBox();
        })
    });

//自动获取
function getSelectVal(val) {
    console.log($(val).attr("rel"), $(val).html());
}
//获取第一个select
console.log($('.selectBox').eq(0).val());

// 宽高设置
function setBox() {
    $('body.hidden').css('min-height', $(window).height());
    $('.y-menu-box,.y-menu,.y-content-r').css('height', $(window).height() - 220);
    $('.y-main-content-r').css('height', $(window).height() - 260);
    if ($('.y-scroll-height').height() > $('.y-main-content-r').height()) {
        $('.y-main-content-r').css('width', $(document).width() - 359 + 22);
    } else {
        $('.y-main-content-r').css('width', $(document).width() - 359);
    }

    //jiusannian add 使mainContent的高度为父元素的全部高度减去70像素的高度
    $(".j-main-content")
        .css('height', '100%')
        .css('height', '-=120px');
    $(".j-content")
        .css('height', '100%')
        .css('height', '-=40px');

    //tabDisplayCont
    $(".j-location-l .tabDisplayCont").css('height', $('.j-location-l').height() - 40).css('width', $('.j-location-l').width());
    //挂单薄
    $(".j-location-r .j-main-content-r").css('height', $('.j-location-r').height() - 70).css('width', $('.j-location-r').width() + 20);

    //交易记录
    $(".j-content-r .j-main-content-r").css('height', $('.j-content-r').height() - 70).css('width', $('.j-content-r').width() + 20);

    //委托记录
    $(".j-location-down-l .j-main-content-r").css('height', $('.j-location-down-l').height() - 70).css('width', $('.j-location-down-l').width() + 20);

    //买/卖
    $(".j-location-down-r .j-trade-operate").css('height', $('.j-location-down-r').height() - 60).css('width', $('.j-location-down-r').width() - 20);

    //个人中心
    $('.j-menu-box,.j-userCenter-menu,.j-userCenter-content .y-content-r').css('height', $(window).height() - 350);
    $('.j-userCenter-content-r').css('height', $(window).height() - 390);
    $('.j-userCenter-content-r').css('width', $('.y-content-r').width() + 22);

    // 菜单宽度
    var u = navigator.userAgent; 
    var isiOS = u.indexOf('Mac OS X'); //ios终端 
    if ($('.y-menu-ul').height() > $('.y-menu-box').height() && isiOS == -1) {
        $('.y-menu').css('width', '322px');
    } else {
        $('.y-menu').css('width', '300px');
    }
}

//换皮肤
function changeSkin() {
    $(this).toggleClass('.y-light-skin');
    if ($(this).hasClass('.y-light-skin')) {
        $('.location-ico,.y-popPay-nextIco').attr('src', 'images/icon/next-light.png')
        $('.sortIcon').attr('src', 'images/icon/tableIco1-light.png')
        $('.y-trade-chageIco').attr('src', 'images/icon/changeIco-light.png')
        $('.y-step-img').attr('src', 'images/step-light.png')
        $('.common-css').attr('href', 'css/common-light.css')


    } else {
        $('.location-ico,.y-popPay-nextIco').attr('src', 'images/icon/next.png')
        $('.y-sortIcon').attr('src', 'images/icon/tableIco1.png')
        $('.y-trade-chageIco').attr('src', 'images/icon/changeIco.png')
        $('.y-step-img').attr('src', 'images/step.png')
        $('.common-css').attr('href', 'css/common.css')
    }
}

// 菜单收缩
$('.y-menu-li')
    .click(function() {
        $('.y-subMenu').hide();
        $('.y-menu-text').removeClass('has-subMenu');
        if ($(this).find('.y-subMenu').length) {
            $(this)
                .find('.y-subMenu')
                .show();
            $(this)
                .find('.y-menu-text')
                .addClass('has-subMenu');
        }
        setBox();
    });
//弹窗关闭
$('.pop-hide,.popbg,.y-popCancel-btn').click(function() {
    $('.y-popBox').addClass('none');
})